home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Environments
/
MacMETH 3.2.4
/
Examples
/
RandomNumbers.MOD
< prev
next >
Wrap
Text File
|
1996-06-20
|
522b
|
26 lines
IMPLEMENTATION MODULE RandomNumbers;
IMPORT MathLib;
VAR Z: LONGINT;
PROCEDURE Uniform(): REAL;
CONST a = 16807D; m = 2147483647D;
q = m DIV a; r = m MOD a;
VAR g: LONGINT;
BEGIN g := a*(Z MOD q) - r*(Z DIV q);
IF g > 0D THEN Z := g ELSE Z := g + m END;
RETURN FLOAT(Z)*(1.0/FLOAT(m))
END Uniform;
PROCEDURE Exp(mu: REAL): REAL;
BEGIN RETURN -MathLib.Ln(Uniform())/mu
END Exp;
PROCEDURE InitSeed(seed: LONGINT);
BEGIN Z := seed
END InitSeed;
BEGIN Z := 1
END RandomNumbers.